package com.abel.bigwater.dataserver.model.qdies

import com.abel.bigwater.data.BcdString
import io.netty.buffer.Unpooled
import org.junit.Test

import org.junit.Assert.*
import org.slf4j.LoggerFactory

class MainPulseBaseDataTest {

    @Test
    fun fill() {
        val buf = Unpooled.buffer()
        MainPacket().apply {
            address = BcdString(byteArrayOf(12, 0, 0, 1), true)
            func = FuncType.SetPulseBase
            data = MainPulseBaseData().also {
                it.internalAddr = 11
                it.pulse = PulseType.HundredLiter
                it.baseRead = 351F
                it.digits = 6
            }

            fill(buf)
        }

        val str = BcdString.create(buf, buf.readableBytes()).bcdString
        lgr.info(str)
        assertEquals("set pulse base", DEMO_SET_PULSE_BASE, str)
    }

    companion object {
        private val lgr = LoggerFactory.getLogger(MainAskTimeDataTest::class.java)

        const val DEMO_SET_PULSE_BASE = "68120000012c080b0143af80000306ca16"
    }
}